package com.zy.business.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zy.business.domain.TbAttendanceRecord;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * @Description:打卡提醒Mapper接口
 * @author: zhangxiaojia
 * @date: 2020/7/16 上午 10:45
 */
public interface AttendanceMapper extends BaseMapper<TbAttendanceRecord> {

    List<TbAttendanceRecord> list(@Param("userId") String userId, @Param("startTime") String startTime, @Param("endTime") String endTime);

    List<TbAttendanceRecord> getListByTime(@Param("userId") String userId, @Param("workDate") String workDate, @Param("startTime") String startTime, @Param("endTime") String endTime);

    @Select("select * from tb_attendance_record where record_id=#{recordId}")
    TbAttendanceRecord getRecordByRecordId(@Param("recordId") String recordId);

    @Select("select work_date from tb_attendance_record where work_date>=#{startTime} and work_date<=#{endTime} GROUP BY work_date")
    List<String> getWorkDateList(@Param("startTime") String startTime, @Param("endTime") String endTime);

    @Select("select * from tb_attendance_record where user_id =#{dingUserId} and work_date =#{workDateTime} GROUP BY user_check_time desc")
    List<TbAttendanceRecord> getListByWorkDateList(@Param("dingUserId") Long dingUserId, @Param("workDateTime") String workDateTime);

    @Select("select * from tb_attendance_record where user_id=#{dingUserId} and date_format(user_check_time,'%Y-%m-%d %H:%i')=#{punchCardTime}")
    TbAttendanceRecord getRecordByUserCheckTime(@Param("dingUserId") String dingUserId, @Param("punchCardTime") String punchCardTime);
}
